<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <canvas width="500" height="500px">
      
    </canvas>
    <script>
        // 获取节点
        let canvas=document.querySelector("canvas")
        let ctx=canvas.getContext("2d")
        
        ctx.strokeStyle="red"
        ctx.moveTo(100,100)
        ctx.lineTo(200,200)
        ctx.stroke()
       ctx.beginPath()
        ctx.strokeStyle="blue"
        ctx.moveTo(200,100)
        ctx.lineTo(300,200)
        ctx.stroke()
        
    </script>
</body>
</html>